<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>Title</title>
    <link rel="stylesheet" href="/houtai/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/houtai/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="/houtai/layuiadmin/style/login.css" media="all">
    <link rel="stylesheet" type="text/css" href="../../css/verify.css">
</head>
<body>
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

    <div id="content" class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>禄舍轩后台管理系统</h2>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <form id="loginForm">
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                    <input type="text" name="tel" id="LAY-user-login-username" lay-verify="required" placeholder="手机号" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                    <input type="password" name="adminUserPwd" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
                </div>
                <!--图片验证码-->
                <div  id="mpanel1">

                </div>
                <div class="layui-form-item" style="margin-bottom: 20px;">
                    <input type="checkbox" name="rememberMe" lay-skin="primary" title="记住密码">
                    <a href="forget.html" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">忘记密码？</a>
                </div>
                <span style="color: red;margin-left: 20px">{{message}}</span>
                <div class="layui-form-item">
                    <input type="button" class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit" value="登 入" @click="login()">
                </div>
            </form>
        </div>
    </div>

</div>
<script type="text/javascript" src="../../js/jquery.min.js" ></script>
<script type="text/javascript" src="../../js/verify.min.js" ></script>

<!--<script type="text/javascript" src="/houtai/js/jquery-2.1.4.js"></script>-->
<script src="/houtai/js/vue.js"></script>

<script src="../../layuiadmin/layui/layui.js"></script>
<script>
    var vue = new Vue({
        el:"#content",
        data:{
            message:""
        },
        created:function(){
            $.ajax({
                url: "/houtai/adminuser/toLogin",
                type: "post",
                dataType:"json",
                success:function (data) {
                    console.log(data);
                    if(data.message == "success"){
                        location.href = "../adminindex.html";
                    }
                }
            })
        },
        methods:{
            login:function () {
                var _this = this;
                $.ajax({
                    url:"/houtai/adminuser/login",
                    data:$("#loginForm").serialize(),
                    type:"post",
                    dataType:"json",
                    success:function (data) {
                        console.log(data);
                        if(data.message == "no user"){
                            _this.message = "用 户 名 不 存 在";
                        }else if(data.message == "password not map"){
                            _this.message = "密 码 错 误";
                        }else if(data.message == "success"){
                            location.href = "../adminindex.html";
                        }
                    }
                })
            }
        }
    });


    layui.config({
        base: '../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'user'], function(){
        var $ = layui.$
            ,setter = layui.setter
            ,admin = layui.admin
            ,form = layui.form
            ,router = layui.router()
            ,search = router.search;

        form.render();
    });
</script>
</body>
</html>